package com.robot.console.util;

import java.io.IOException;
import java.nio.channels.SocketChannel;
import java.util.concurrent.ConcurrentHashMap;

public class Connection
{
	private String serverAddress = "";
	private int serverPort;
	private boolean zip = false;
	private SocketChannel channel;
	private ConcurrentHashMap<Object, Object> attributes = new ConcurrentHashMap<Object, Object>();

	public Connection(String serverAddress, int serverPort, boolean zip)
	{
		this.serverAddress = serverAddress;
		this.serverPort = serverPort;
		this.zip = zip;
	}

	public SocketChannel getChannel()
	{
		return channel;
	}

	public void setAttribute(Object key, Object value)
	{
		this.attributes.put(key, value);
	}

	public Object getAttribute(Object key)
	{
		return this.attributes.get(key);
	}

	public void close()
	{
		try
		{
			channel.close();
		}
		catch (IOException e)
		{
		}
	}

	public boolean isZip()
	{
		return zip;
	}

	public void setZip(boolean zip)
	{
		this.zip = zip;
	}

	public String getServerAddress()
	{
		return serverAddress;
	}

	public int getServerPort()
	{
		return serverPort;
	}

	public void setServerPort(int serverPort)
	{
		this.serverPort = serverPort;
	}
}
